group { name: "elm/radio/base/default";
#define SELECTED 8
   script {
      BUTTONMODE_SCRIPT
      public sel;
      public eval_sel(m) {
         if (m) {
            set_state(PART:"ck_check", "selected", 0.0);
         } else {
            set_state(PART:"ck_check", "default", 0.0);
         }
      }
   }
   parts {
      part { name: "shadow"; type: SPACER;
         description { state: "default";
         }
         desc { "pressed"; inherit;
         }
         desc { "disabled"; inherit;
         }
      }
      swallow { "elm.swallow.background"; nomouse;
         desc { "default";
            visible: 0;
         }
         desc { "visible"; inherit;
            visible: 1;
         }
      }
      rect { "icon_clip";
         desc { "default";
            color: 255 255 255 255; // no cc
         }
         desc { "pressed"; inherit;
            color: 255 255 255 255; // no cc
         }
         desc { "disabled"; inherit;
            color: 255 255 255 64; // no cc
         }
      }
      swallow { "elm.swallow.content"; nomouse;
         clip_to: "icon_clip";
         scale: 1;
         desc { "default";
            fixed: 1 0;
            align: 0.0 0.5;
            rel1.to_x: "base";
            rel2.to_x: "base";
            rel1.offset: 4 4;
            rel1.relative: 1.0 0.0;
            rel2.relative: 0.0 1.0;
            rel2.offset: 4 -5;
            visible: 0;
            offscale;
         }
         desc { "visible"; inherit;
            fixed: 1 0;
            aspect: 1.0 1.0;
            min: ICMIN ICMIN;
            visible: 1;
         }
         desc { "icononly"; inherit;
            fixed: 0 0;
            align: 0.5 0.5;
            rel2.relative: 1.0 1.0;
            rel2.offset: -5 -5;
            rel2.to_x: "";
            visible: 1;
            min: ICMIN ICMIN;
         }
      }
      part { name: "base"; type: RECT;
         scale: 1;
         description { state: "default";
            fixed: 1 0;
            align: 0.0 0.5;
            min: 13 13;
            max: 13 13;
            rel1.offset: 4 4;
            rel2.relative: 0.0 1.0;
            rel2.offset: 4 -5;
            aspect: 1.0 1.0; aspect_preference: VERTICAL;
            offscale;
            visible: 0;
            offscale;
         }
         desc { "pressed"; inherit;
         }
         desc { "disabled"; inherit;
         }
      }
      part { name: "ck_bg";
         scale: 1;
         description { state: "default" 0.0;
            fixed: 1 1;
            rel.to: "base";
            image.normal: "i-radio";
            min: 15 15;
            max: 15 15;
            color_class: "/bg/normal/radio/base";
         }
         desc { "disabled"; inherit;
            color_class: "/bg/disabled/radio/base";
         }
      }
      part { name: "ck_check";
         scale: 1;
         description { state: "default" 0.0;
            color_class: "/fg/selected/radio/radio";
            rel.to: "base";
            image.normal: "i-radio";
            min: 15 15;
            max: 15 15;
            fixed: 1 1;
            visible: 0;
         }
         description { state: "selected" 0.0;
            inherit: "default" 0.0;
            visible: 1;
         }
         desc { "disabled"; inherit;
            visible: 0;
         }
      }
      part { name: "ck_press";
         scale: 1;
         description { state: "default" 0.0;
            color_class: "/fg/pressed/radio/radio";
            fixed: 1 1;
            rel.to: "base";
            image.normal: "i-radio";
            min: 15 15;
            max: 15 15;
            visible: 0;
         }
         description { state: "pressed" 0.0;
            inherit: "default" 0.0;
            visible: 1;
         }
      }
      text { "elm.text"; nomouse;
         scale: 1;
         desc { "default";
            fixed: 0 1;
            color_class: "/fg/normal/radio/text";
            rel1.offset: 0 4;
            rel1.relative: 1.0 0.0;
            rel1.to_x: "elm.swallow.content";
            rel2.offset: -5 -5;
            text { font: FN; size: 10;
               align: 0.0 0.5;
               min: 0 0;
            }
            visible: 0;
            offscale;
            min: 0 ICMIN;
         }
         desc { "visible"; inherit;
            fixed: 0 0;
            rel1.offset: 4 4;
            text.min: 1 1;
            text.ellipsis: -1;
            visible: 1;
         }
         desc { "pressed_visible"; inherit;
            fixed: 0 0;
            color_class: "/fg/pressed/radio/text";
            rel1.offset: 4 4;
            text.min: 1 1;
            text.ellipsis: -1;
            visible: 1;
         }
         desc { "textonly"; inherit;
            fixed: 0 0;
            text.min: 1 1;
            text.ellipsis: -1;
            visible: 1;
         }
         desc { "pressed_textonly"; inherit;
            fixed: 0 0;
            color_class: "/fg/pressed/radio/text";
            text.min: 1 1;
            text.ellipsis: -1;
            visible: 1;
         }
         desc { "disabled_visible"; inherit;
            fixed: 0 0;
            color_class: "/fg/disabled/radio/text";
            rel1.offset: 4 4;
            text.min: 1 1;
            text.ellipsis: -1;
            visible: 1;
         }
         desc { "disabled_textonly"; inherit;
            fixed: 0 0;
            color_class: "/fg/disabled/radio/text";
            text.min: 1 1;
            text.ellipsis: -1;
            visible: 1;
         }
      }
      rect { "event";
         ignore_flags: ON_HOLD;
         desc { "default";
            color: 0 0 0 0; // no cc
         }
         desc { "disabled"; inherit;
            visible: 0;
         }
      }
   }
   programs {
      program { signal: "mouse,clicked,1"; source: "event";
         action: SIGNAL_EMIT "elm,action,radio,toggle" "elm";
      }
      program { signal: "elm,state,radio,on"; source: "elm";
         script {
            new m = get_int(sel) | SELECTED;
            set_int(sel, m);
            eval_sel(m);
         }
      }
      program { signal: "elm,state,radio,off"; source: "elm";
         script {
            new m = get_int(sel) & ~SELECTED;
            set_int(sel, m);
            eval_sel(m);
         }
      }
      program { signal: "mouse,down,1"; source: "event";
         action: SIGNAL_EMIT "elm,action,press" "elm";
         after: "button_click_anim";
      }
      program { name: "button_click_anim";
         script { flag_set(PRESSED); }
      }
      program { signal: "mouse,down,1"; source: "event";
         script { eval_sel(get_int(sel) | SELECTED); }
      }
      program { signal: "mouse,up,1"; source: "event";
         action: SIGNAL_EMIT "elm,action,unpress" "elm";
         after: "button_unclick_anim";
      }
      program { name: "button_unclick_anim";
         script { flag_unset(PRESSED); }
      }
      program { signal: "mouse,up,1"; source: "event";
         script { eval_sel(get_int(sel)); }
      }
      program { signal: "mouse,clicked,1"; source: "event";
         action: SIGNAL_EMIT "elm,action,click" "elm";
      }
      program { signal: "elm,state,text,visible"; source: "elm";
         script { flag_set(LABEL); }
      }
      program { signal: "elm,state,text,hidden"; source: "elm";
         script { flag_unset(LABEL); }
      }
      program { signal: "elm,state,icon,visible"; source: "elm";
         script { flag_set(ICON); }
      }
      program { signal: "elm,state,icon,hidden"; source: "elm";
         script { flag_unset(ICON); }
      }
      program { signal: "elm,state,background,visible"; source: "elm";
         script { flag_set(BACKGROUND); }
      }
      program { signal: "elm,state,background,hidden"; source: "elm";
         script { flag_unset(BACKGROUND); }
      }
      program { signal: "elm,state,disabled"; source: "elm";
         script { flag_set(DISABLE); }
      }
      program { signal: "elm,state,enabled"; source: "elm";
         script { flag_unset(DISABLE); }
      }
      program { signal: "elm,state,disabled"; source: "elm";
         action:  STATE_SET "disabled" 0.0;
         target: "ck_check";
         target: "ck_bg";
      }
      program { signal: "elm,state,enabled"; source: "elm";
         action:  STATE_SET "default" 0.0;
         target: "ck_check";
         target: "ck_bg";
      }
      program { signal: "mouse,down,1"; source: "event";
         action: STATE_SET "pressed" 0.0;
         target: "ck_press";
      }
      program { signal: "mouse,up,1"; source: "event";
         action: STATE_SET "default" 0.0;
         target: "ck_press";
      }
   }
}

group { name: "elm/radio/base/plain";
   alias: "elm/check/base/plain";
   script {
      public btmode;
      public eval_mode(m) {
         new m1 = m & MASK;
         new d = m & DISABLE;
         new s = m & SELECTED;
         if (s) {
            if (!d) {
               set_state(PART:"shadow", "selected", 0.0);
               set_state(PART:"base", "selected", 0.0);
               set_state(PART:"bar", "selected", 0.0);
            } else {
               set_state(PART:"shadow", "selected", 0.0);
               set_state(PART:"base", "disabled", 0.0);
               set_state(PART:"bar", "default", 0.0);
            }
         } else {
            if (!d) {
               set_state(PART:"shadow", "default", 0.0);
               set_state(PART:"base", "default", 0.0);
               set_state(PART:"bar", "default", 0.0);
            } else {
               set_state(PART:"shadow", "selected", 0.0);
               set_state(PART:"base", "disabled", 0.0);
               set_state(PART:"bar", "default", 0.0);
            }
         }
         if (m1 == (ICON | LABEL)) {
            if (!d) {
               set_state(PART:"elm.swallow.content", "visible", 0.0);
               if (s) set_state(PART:"elm.text", "selected", 0.0);
               else set_state(PART:"elm.text", "visible", 0.0);
               set_state(PART:"clip", "default", 0.0);
               set_state(PART:"event", "default", 0.0);
            } else {
               set_state(PART:"elm.swallow.content", "visible", 0.0);
               set_state(PART:"elm.text", "disabled_visible", 0.0);
               set_state(PART:"clip", "disabled", 0.0);
               set_state(PART:"event", "disabled", 0.0);
            }
         } else if (m1 == (ICON)) {
            if (!d) {
               set_state(PART:"elm.swallow.content", "icononly", 0.0);
               set_state(PART:"elm.text", "default", 0.0);
               set_state(PART:"clip", "default", 0.0);
               set_state(PART:"event", "default", 0.0);
            } else {
               set_state(PART:"elm.swallow.content", "icononly", 0.0);
               set_state(PART:"elm.text", "default", 0.0);
               set_state(PART:"clip", "disabled", 0.0);
               set_state(PART:"event", "disabled", 0.0);
            }
         } else if (m1 == (LABEL)) {
            if (!d) {
               set_state(PART:"elm.swallow.content", "default", 0.0);
               if (s) set_state(PART:"elm.text", "selected", 0.0);
               else set_state(PART:"elm.text", "visible", 0.0);
               set_state(PART:"clip", "default", 0.0);
               set_state(PART:"event", "default", 0.0);
            } else {
               set_state(PART:"elm.swallow.content", "default", 0.0);
               set_state(PART:"elm.text", "disabled_visible", 0.0);
               set_state(PART:"clip", "disabled", 0.0);
               set_state(PART:"event", "disabled", 0.0);
            }
         } else {
            if (!d) {
               set_state(PART:"elm.swallow.content", "default", 0.0);
               set_state(PART:"elm.text", "default", 0.0);
               set_state(PART:"clip", "default", 0.0);
               set_state(PART:"event", "default", 0.0);
            } else {
               set_state(PART:"elm.swallow.content", "default", 0.0);
               set_state(PART:"elm.text", "default", 0.0);
               set_state(PART:"clip", "disabled", 0.0);
               set_state(PART:"event", "disabled", 0.0);
            }
         }
      }
   }
   parts {
      part { name: "shadow"; mouse_events: 0;
         scale: 1;
         description { state: "default" 0.0;
            rel.to: "base";
            WIN_SHADOW_SMALL;
            color_class: "/shadow/normal/button";
         }
         description { state: "selected" 0.0; inherit;
            image.border_scale_by: 0.1;
            rel1.offset: -2 -1;
            rel2.offset: 0 1;
            color_class: "/shadow/pressed/button";
         }
      }
      rect { name: "base"; nomouse;
         scale: 1;
         desc { "default";
            color_class: "/bg/normal/button";
            rel1.offset: 2 2;
            rel2.offset: -3 -3;
            offscale;
         }
         desc { "selected"; inherit;
            color_class: "/bg/selected/button";
            rel1.offset: 3 3;
            rel2.offset: -4 -4;
            offscale;
         }
         desc { "disabled"; inherit;
            color_class: "/bg/disabled/button";
         }
      }
      part { name: "clip"; type: RECT;
         description { state: "default" 0.0;
         }
         description { state: "disabled" 0.0;
            inherit: "default" 0.0;
            color: 255 255 255 64; // no cc
         }
      }
      part { name: "elm.swallow.content"; type: SWALLOW;
         scale: 1;
         clip_to: "clip";
         description { state: "default" 0.0;
            fixed: 1 0;
            visible: 0;
            align: 0.0 0.5;
            max: 0 0;
            rel1.offset: 0 8;
            rel2.relative: 0.0 1.0;
            rel2.offset: 0 -9;
            offscale;
         }
         description { state: "icononly" 0.0;
           inherit: "default" 0.0;
            visible: 1;
            align: 0.5 0.5;
            min: ICMIN ICMIN;
            max: -1 -1;
            rel1.offset: 8 8;
            rel2.relative: 1.0 1.0;
            rel2.offset: -9 -9;
            fixed: 0 0;
         }
         description { state: "visible" 0.0;
            inherit: "default" 0.0;
            visible: 1;
            aspect: 1.0 1.0;
            rel1.offset: 8 8;
            rel2.offset: 8 -9;
            min: ICMIN ICMIN;
            max: -1 -1;
         }
      }
      part { name: "elm.text"; type: TEXT; mouse_events: 0;
         scale: 1;
         description { state: "default" 0.0;
            fixed: 1 1;
            rel1.offset: 0 8;
            rel1.to_x: "elm.swallow.content";
            rel1.relative: 1.0 0.0;
            rel2.offset: -9 -9;
            color_class: "/fg/normal/button";
            text { font: FN; size: 10;
              min: 0 0;
              align: 0.0 0.5;
              text_class: "radio";
            }
            offscale;
            min: 0 ICMIN;
         }
         description { state: "disabled" 0.0;
            inherit: "default" 0.0;
            color_class: "/fg/disabled/button";
         }
         description { state: "visible" 0.0;
            inherit: "default" 0.0;
            fixed: 0 0;
            rel1.offset: 8 8;
            visible: 1;
            text.min: 1 1;
            text.ellipsis: -1;
         }
         description { state: "selected" 0.0;
            inherit: "visible" 0.0;
            color_class: "/fg/selected/button";
         }
         description { state: "disabled_visible" 0.0;
            inherit: "default" 0.0;
            color_class: "/fg/disabled/button";
            rel1.offset: 8 8;
            visible: 1;
            text.min: 1 1;
            text.ellipsis: -1;
         }
      }
      rect { "bar"; nomouse;
         scale: 1;
         desc { "default";
            color_class: "/fg/selected/button/bar";
            color: 255 255 255 0; // no cc
            fixed: 0 1;
            rel.to: "base";
            rel1.relative: 0.0 1.0;
            rel1.offset: 0 -1;
            align: 0.5 1.0;
            visible: 0;
         }
         desc { "selected"; inherit;
           min: 0 5;
           color: 255 255 255 255; // no cc
           visible: 1;
         }
      }
      part { name: "event"; type: RECT;
         description { state: "default" 0.0;
            color: 0 0 0 0; // no cc
         }
         description { state: "disabled" 0.0;
            inherit: "default" 0.0;
            visible: 0;
         }
      }
   }
   programs {
      program { signal: "mouse,down,1"; source: "event";
         script {
            new m = get_int(btmode);
            eval_mode(m | SELECTED);
         }
      }
      program { signal: "mouse,up,1"; source: "event";
         script {
            new m = get_int(btmode);
            eval_mode(m);
         }
      }
      program { signal: "mouse,clicked,1"; source: "event";
         action: SIGNAL_EMIT "elm,action,radio,toggle" "elm";
         after: "check_toggle";
      }
      program { name: "check_toggle";
         action: SIGNAL_EMIT "elm,action,check,toggle" "elm";
      }
      program { signal: "elm,state,*,on"; source: "elm";
         script {
            new m = get_int(btmode);
            m |= SELECTED; set_int(btmode, m);
            eval_mode(m);
         }
      }
      program { signal: "elm,state,*,off"; source: "elm";
         script {
            new m = get_int(btmode);
            m &= ~SELECTED; set_int(btmode, m);
            eval_mode(m);
         }
      }
      program { signal: "elm,state,text,visible"; source: "elm";
         script {
            new m = get_int(btmode);
            m |= LABEL; set_int(btmode, m);
            eval_mode(m);
         }
      }
      program { signal: "elm,state,text,hidden"; source: "elm";
         script {
            new m = get_int(btmode);
            m &= ~LABEL; set_int(btmode, m);
            eval_mode(m);
         }
      }
      program { signal: "elm,state,icon,visible"; source: "elm";
         script {
            new m = get_int(btmode);
            m |= ICON; set_int(btmode, m);
            eval_mode(m);
         }
      }
      program { signal: "elm,state,icon,hidden"; source: "elm";
         script {
            new m = get_int(btmode);
            m &= ~ICON; set_int(btmode, m);
            eval_mode(m);
         }
      }
      program { signal: "elm,state,disabled"; source: "elm";
         script {
            new m = get_int(btmode);
            m |= DISABLE; set_int(btmode, m);
            eval_mode(m);
         }
      }
      program { signal: "elm,state,enabled"; source: "elm";
         script {
            new m = get_int(btmode);
            m &= ~DISABLE; set_int(btmode, m);
            eval_mode(m);
         }
      }
   }
}

group { name: "elm/radio/base/icon";
   alias: "elm/check/base/icon";
   script {
      public btmode;
      public eval_mode(m) {
         new m1 = m & MASK;
         new d = m & DISABLE;
         new s = m & SELECTED;
         if (s) {
            if (!d) {
               set_state(PART:"shadow", "selected", 0.0);
               set_state(PART:"base", "selected", 0.0);
               set_state(PART:"bar", "selected", 0.0);
            } else {
               set_state(PART:"shadow", "selected", 0.0);
               set_state(PART:"base", "disabled", 0.0);
               set_state(PART:"bar", "default", 0.0);
            }
         } else {
            if (!d) {
               set_state(PART:"shadow", "default", 0.0);
               set_state(PART:"base", "default", 0.0);
               set_state(PART:"bar", "default", 0.0);
            } else {
               set_state(PART:"shadow", "selected", 0.0);
               set_state(PART:"base", "disabled", 0.0);
               set_state(PART:"bar", "default", 0.0);
            }
         }
         if (m1 == (ICON | LABEL)) {
            if (!d) {
               set_state(PART:"elm.swallow.content", "visible", 0.0);
               if (s) set_state(PART:"elm.text", "selected", 0.0);
               else set_state(PART:"elm.text", "visible", 0.0);
               set_state(PART:"clip", "default", 0.0);
               set_state(PART:"event", "default", 0.0);
            } else {
               set_state(PART:"elm.swallow.content", "visible", 0.0);
               set_state(PART:"elm.text", "disabled_visible", 0.0);
               set_state(PART:"clip", "disabled", 0.0);
               set_state(PART:"event", "disabled", 0.0);
            }
         } else if (m1 == (ICON)) {
            if (!d) {
               set_state(PART:"elm.swallow.content", "icononly", 0.0);
               set_state(PART:"elm.text", "default", 0.0);
               set_state(PART:"clip", "default", 0.0);
               set_state(PART:"event", "default", 0.0);
            } else {
               set_state(PART:"elm.swallow.content", "icononly", 0.0);
               set_state(PART:"elm.text", "default", 0.0);
               set_state(PART:"clip", "disabled", 0.0);
               set_state(PART:"event", "disabled", 0.0);
            }
         } else if (m1 == (LABEL)) {
            if (!d) {
               set_state(PART:"elm.swallow.content", "default", 0.0);
               if (s) set_state(PART:"elm.text", "selected", 0.0);
               else set_state(PART:"elm.text", "visible", 0.0);
               set_state(PART:"clip", "default", 0.0);
               set_state(PART:"event", "default", 0.0);
            } else {
               set_state(PART:"elm.swallow.content", "default", 0.0);
               set_state(PART:"elm.text", "disabled_visible", 0.0);
               set_state(PART:"clip", "disabled", 0.0);
               set_state(PART:"event", "disabled", 0.0);
            }
         } else {
            if (!d) {
               set_state(PART:"elm.swallow.content", "default", 0.0);
               set_state(PART:"elm.text", "default", 0.0);
               set_state(PART:"clip", "default", 0.0);
               set_state(PART:"event", "default", 0.0);
            } else {
               set_state(PART:"elm.swallow.content", "default", 0.0);
               set_state(PART:"elm.text", "default", 0.0);
               set_state(PART:"clip", "disabled", 0.0);
               set_state(PART:"event", "disabled", 0.0);
            }
         }
      }
   }
   parts {
      part { name: "shadow"; mouse_events: 0;
         scale: 1;
         description { state: "default" 0.0;
            rel.to: "base";
            WIN_SHADOW_SMALL;
            color_class: "/shadow/normal/button";
         }
         description { state: "selected" 0.0; inherit;
            image.border_scale_by: 0.1;
            rel1.offset: -2 -1;
            rel2.offset: 0 1;
            color_class: "/shadow/pressed/button";
         }
      }
      rect { name: "base"; nomouse;
         scale: 1;
         desc { "default";
            color_class: "/bg/normal/button";
            rel1.offset: 2 2;
            rel2.offset: -3 -3;
            offscale;
         }
         desc { "selected"; inherit;
            color_class: "/bg/selected/button";
            rel1.offset: 3 3;
            rel2.offset: -4 -4;
            offscale;
         }
         desc { "disabled"; inherit;
            color_class: "/bg/disabled/button";
         }
      }
      part { name: "clip"; type: RECT;
         description { state: "default" 0.0;
         }
         description { state: "disabled" 0.0;
            inherit: "default" 0.0;
            color: 255 255 255 64; // no cc
         }
      }
      part { name: "elm.swallow.content"; type: SWALLOW;
         scale: 1;
         clip_to: "clip";
         description { state: "default" 0.0;
            fixed: 0 1;
            visible: 0;
            align: 0.5 0.0;
            max: 0 0;
            rel1.offset: 8 0;
            rel2.relative: 1.0 0.0;
            rel2.offset: -9 0;
            offscale;
         }
         description { state: "icononly" 0.0;
           inherit: "default" 0.0;
            visible: 1;
            align: 0.5 0.5;
            min: ICMIN ICMIN;
            max: -1 -1;
            rel1.offset: 8 8;
            rel2.offset: -9 -9;
            rel2.relative: 1.0 1.0;
            fixed: 0 0;
         }
         description { state: "visible" 0.0;
            inherit: "default" 0.0;
            visible: 1;
            aspect: 1.0 1.0;
            rel1.offset: 8 8;
            rel2.offset: -9 8;
            min: ICMIN ICMIN;
            max: -1 -1;
            fixed: 1 1;
         }
      }
      part { name: "elm.text"; type: TEXT; mouse_events: 0;
         scale: 1;
         description { state: "default" 0.0;
            fixed: 1 1;
            rel1.offset: 8 0;
            rel1.to_y: "elm.swallow.content";
            rel1.relative: 0.0 1.0;
            rel2.offset: -9 -9;
            color_class: "/fg/normal/button";
            text { font: FN; size: 10;
              min: 0 0;
              align: 0.5 1.0;
              text_class: "radio";
            }
            offscale;
            min: 0 ICMIN;
         }
         description { state: "disabled" 0.0;
            inherit: "default" 0.0;
            color_class: "/fg/disabled/button";
         }
         description { state: "visible" 0.0;
            inherit: "default" 0.0;
            fixed: 0 0;
            rel1.offset: 8 8;
            visible: 1;
            text.min: 1 1;
            text.ellipsis: -1;
         }
         description { state: "selected" 0.0;
            inherit: "visible" 0.0;
            color_class: "/fg/selected/button";
         }
         description { state: "disabled_visible" 0.0;
            inherit: "default" 0.0;
            color_class: "/fg/disabled/button";
            rel1.offset: 8 8;
            visible: 1;
            text.min: 1 1;
            text.ellipsis: -1;
         }
      }
      rect { "bar"; nomouse;
         scale: 1;
         desc { "default";
            color_class: "/fg/selected/button/bar";
            color: 255 255 255 0; // no cc
            fixed: 0 1;
            rel.to: "base";
            rel1.relative: 0.0 1.0;
            rel1.offset: 0 -1;
            align: 0.5 1.0;
            visible: 0;
         }
         desc { "selected"; inherit;
           min: 0 5;
           color: 255 255 255 255; // no cc
           visible: 1;
         }
      }
      part { name: "event"; type: RECT;
         description { state: "default" 0.0;
            color: 0 0 0 0; // no cc
         }
         description { state: "disabled" 0.0;
            inherit: "default" 0.0;
            visible: 0;
         }
      }
   }
   programs {
      program { signal: "mouse,down,1"; source: "event";
         script {
            new m = get_int(btmode);
            eval_mode(m | SELECTED);
         }
      }
      program { signal: "mouse,up,1"; source: "event";
         script {
            new m = get_int(btmode);
            eval_mode(m);
         }
      }
      program { signal: "mouse,clicked,1"; source: "event";
         action: SIGNAL_EMIT "elm,action,radio,toggle" "elm";
         after: "check_toggle";
      }
      program { name: "check_toggle";
         action: SIGNAL_EMIT "elm,action,check,toggle" "elm";
      }
      program { signal: "elm,state,*,on"; source: "elm";
         script {
            new m = get_int(btmode);
            m |= SELECTED; set_int(btmode, m);
            eval_mode(m);
         }
      }
      program { signal: "elm,state,*,off"; source: "elm";
         script {
            new m = get_int(btmode);
            m &= ~SELECTED; set_int(btmode, m);
            eval_mode(m);
         }
      }
      program { signal: "elm,state,text,visible"; source: "elm";
         script {
            new m = get_int(btmode);
            m |= LABEL; set_int(btmode, m);
            eval_mode(m);
         }
      }
      program { signal: "elm,state,text,hidden"; source: "elm";
         script {
            new m = get_int(btmode);
            m &= ~LABEL; set_int(btmode, m);
            eval_mode(m);
         }
      }
      program { signal: "elm,state,icon,visible"; source: "elm";
         script {
            new m = get_int(btmode);
            m |= ICON; set_int(btmode, m);
            eval_mode(m);
         }
      }
      program { signal: "elm,state,icon,hidden"; source: "elm";
         script {
            new m = get_int(btmode);
            m &= ~ICON; set_int(btmode, m);
            eval_mode(m);
         }
      }
      program { signal: "elm,state,disabled"; source: "elm";
         script {
            new m = get_int(btmode);
            m |= DISABLE; set_int(btmode, m);
            eval_mode(m);
         }
      }
      program { signal: "elm,state,enabled"; source: "elm";
         script {
            new m = get_int(btmode);
            m &= ~DISABLE; set_int(btmode, m);
            eval_mode(m);
         }
      }
   }
}

group { name: "elm/radio/base/sort_header";
   script {
      BUTTONMODE_SCRIPT
      public sel;
      public eval_sel(m) {
         if (m) {
            set_state(PART:"ck_check", "selected", 0.0);
         } else {
            set_state(PART:"ck_check", "default", 0.0);
         }
      }
   }
   parts {
      part { name: "shadow"; type: SPACER;
         description { state: "default";
         }
         desc { "pressed"; inherit;
         }
         desc { "disabled"; inherit;
         }
      }
      swallow { "elm.swallow.background"; nomouse;
         desc { "default";
            visible: 0;
         }
         desc { "visible"; inherit;
            visible: 1;
         }
      }
      rect { "icon_clip";
         desc { "default";
            color: 255 255 255 255; // no cc
         }
         desc { "pressed"; inherit;
            color: 255 255 255 255; // no cc
         }
         desc { "disabled"; inherit;
            color: 255 255 255 64; // no cc
         }
      }
      swallow { "elm.swallow.content"; nomouse;
         clip_to: "icon_clip";
         scale: 1;
         desc { "default";
            fixed: 1 0;
            align: 0.0 0.5;
            rel1.to_x: "base";
            rel2.to_x: "base";
            rel1.offset: 4 4;
            rel1.relative: 1.0 0.0;
            rel2.relative: 0.0 1.0;
            rel2.offset: 4 -5;
            visible: 0;
            offscale;
         }
         desc { "visible"; inherit;
            fixed: 1 0;
            aspect: 1.0 1.0;
            min: ICMIN ICMIN;
            visible: 1;
         }
         desc { "icononly"; inherit;
            fixed: 0 0;
            align: 0.5 0.5;
            rel2.relative: 1.0 1.0;
            rel2.offset: -5 -5;
            rel2.to_x: "";
            visible: 1;
            min: ICMIN ICMIN;
         }
      }
      part { name: "base"; type: RECT;
         scale: 1;
         description { state: "default";
            fixed: 1 0;
            align: 0.0 0.5;
            min: 13 13;
            max: 13 13;
            rel1.offset: 4 4;
            rel2.relative: 0.0 1.0;
            rel2.offset: 4 -5;
            aspect: 1.0 1.0; aspect_preference: VERTICAL;
            offscale;
            visible: 0;
            offscale;
         }
         desc { "pressed"; inherit;
         }
         desc { "disabled"; inherit;
         }
      }
      part { name: "ck_bg";
         scale: 1;
         description { state: "default" 0.0;
            fixed: 1 1;
            rel.to: "base";
            image.normal: "i-arrow-d";
            min: 15 15;
            max: 15 15;
            color_class: "/bg/normal/radio/base";
         }
         desc { "disabled"; inherit;
            color_class: "/bg/disabled/radio/base";
         }
      }
      part { name: "ck_check";
         scale: 1;
         description { state: "default" 0.0;
            color_class: "/fg/selected/radio/radio";
            rel.to: "base";
            image.normal: "i-arrow-d";
            min: 15 15;
            max: 15 15;
            fixed: 1 1;
            visible: 0;
         }
         description { state: "selected" 0.0;
            inherit: "default" 0.0;
            visible: 1;
         }
         desc { "disabled"; inherit;
            visible: 0;
         }
      }
      part { name: "ck_press";
         scale: 1;
         description { state: "default" 0.0;
            color_class: "/fg/pressed/radio/radio";
            fixed: 1 1;
            rel.to: "base";
            image.normal: "i-arrow-d";
            min: 15 15;
            max: 15 15;
            visible: 0;
         }
         description { state: "pressed" 0.0;
            inherit: "default" 0.0;
            visible: 1;
         }
      }
      text { "elm.text"; nomouse;
         scale: 1;
         desc { "default";
            fixed: 0 1;
            color_class: "/fg/normal/radio/text";
            rel1.offset: 0 4;
            rel1.relative: 1.0 0.0;
            rel1.to_x: "elm.swallow.content";
            rel2.offset: -5 -5;
            text { font: FN; size: 10;
               align: 0.0 0.5;
               min: 0 0;
               ellipsis: 0;
            }
            visible: 0;
            offscale;
            min: 0 ICMIN;
         }
         desc { "visible"; inherit;
            fixed: 0 0;
            rel1.offset: 4 4;
//            text.min: 1 1;
//            text.ellipsis: -1;
            visible: 1;
         }
         desc { "pressed_visible"; inherit;
            fixed: 0 0;
            color_class: "/fg/pressed/radio/text";
            rel1.offset: 4 4;
//            text.min: 1 1;
//            text.ellipsis: -1;
            visible: 1;
         }
         desc { "textonly"; inherit;
            fixed: 0 0;
//            text.min: 1 1;
//            text.ellipsis: -1;
            visible: 1;
         }
         desc { "pressed_textonly"; inherit;
            fixed: 0 0;
            color_class: "/fg/pressed/radio/text";
//            text.min: 1 1;
//            text.ellipsis: -1;
            visible: 1;
         }
         desc { "disabled_visible"; inherit;
            fixed: 0 0;
            color_class: "/fg/disabled/radio/text";
            rel1.offset: 4 4;
//            text.min: 1 1;
//            text.ellipsis: -1;
            visible: 1;
         }
         desc { "disabled_textonly"; inherit;
            fixed: 0 0;
            color_class: "/fg/disabled/radio/text";
//            text.min: 1 1;
//            text.ellipsis: -1;
            visible: 1;
         }
      }
      rect { "event";
         ignore_flags: ON_HOLD;
         desc { "default";
            color: 0 0 0 0; // no cc
         }
         desc { "disabled"; inherit;
            visible: 0;
         }
      }
   }
   programs {
      program { signal: "mouse,clicked,1"; source: "event";
         action: SIGNAL_EMIT "elm,action,radio,toggle" "elm";
      }
      program { signal: "elm,state,radio,on"; source: "elm";
         script {
            new m = get_int(sel) | SELECTED;
            set_int(sel, m);
            eval_sel(m);
         }
      }
      program { signal: "elm,state,radio,off"; source: "elm";
         script {
            new m = get_int(sel) & ~SELECTED;
            set_int(sel, m);
            eval_sel(m);
         }
      }
      program { signal: "mouse,down,1"; source: "event";
         action: SIGNAL_EMIT "elm,action,press" "elm";
         after: "button_click_anim";
      }
      program { name: "button_click_anim";
         script { flag_set(PRESSED); }
      }
      program { signal: "mouse,down,1"; source: "event";
         script { eval_sel(get_int(sel) | SELECTED); }
      }
      program { signal: "mouse,up,1"; source: "event";
         action: SIGNAL_EMIT "elm,action,unpress" "elm";
         after: "button_unclick_anim";
      }
      program { name: "button_unclick_anim";
         script { flag_unset(PRESSED); }
      }
      program { signal: "mouse,up,1"; source: "event";
         script { eval_sel(get_int(sel)); }
      }
      program { signal: "mouse,clicked,1"; source: "event";
         action: SIGNAL_EMIT "elm,action,click" "elm";
      }
      program { signal: "elm,state,text,visible"; source: "elm";
         script { flag_set(LABEL); }
      }
      program { signal: "elm,state,text,hidden"; source: "elm";
         script { flag_unset(LABEL); }
      }
      program { signal: "elm,state,icon,visible"; source: "elm";
         script { flag_set(ICON); }
      }
      program { signal: "elm,state,icon,hidden"; source: "elm";
         script { flag_unset(ICON); }
      }
      program { signal: "elm,state,background,visible"; source: "elm";
         script { flag_set(BACKGROUND); }
      }
      program { signal: "elm,state,background,hidden"; source: "elm";
         script { flag_unset(BACKGROUND); }
      }
      program { signal: "elm,state,disabled"; source: "elm";
         script { flag_set(DISABLE); }
      }
      program { signal: "elm,state,enabled"; source: "elm";
         script { flag_unset(DISABLE); }
      }
      program { signal: "elm,state,disabled"; source: "elm";
         action:  STATE_SET "disabled" 0.0;
         target: "ck_check";
         target: "ck_bg";
      }
      program { signal: "elm,state,enabled"; source: "elm";
         action:  STATE_SET "default" 0.0;
         target: "ck_check";
         target: "ck_bg";
      }
      program { signal: "mouse,down,1"; source: "event";
         action: STATE_SET "pressed" 0.0;
         target: "ck_press";
      }
      program { signal: "mouse,up,1"; source: "event";
         action: STATE_SET "default" 0.0;
         target: "ck_press";
      }
   }
}
